/**
 * 本地存储localStorage
 */
// 获取localStorage
export const getLocalStorage = name => {
  const data = window.localStorage.getItem(name)
  try {
    return JSON.parse(data)
  } catch (err) {
    return data
  }
}
// 设置localStorage
export const setLocalStorage = (name, value) => {
  if (typeof value === 'object') {
    value = JSON.stringify(value)
  }
  window.localStorage.setItem(name, value)
}
// 删除localStorage
export const removeLocalStorage = name => {
  window.localStorage.removeItem(name)
}
/**
 * 会话存储 sessionStorage
 */
// 获取sessionStorage
export const getSessionStorage = name => {
  const data = window.sessionStorage.getItem(name)
  try {
    return JSON.parse(data)
  } catch (err) {
    return data
  }
}
// 设置sessionStorage
export const setSessionStorage = (name, value) => {
  if (typeof value === 'object') {
    value = JSON.stringify(value)
  }
  window.sessionStorage.setItem(name, value)
}
// 删除sessionStorage
export const removeSessionStorage = name => {
  window.sessionStorage.removeItem(name)
}
